home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Pascal Super Library
/
Pascal Super Library (CW International)(1997).bin
/
DELPHI32
/
DATETIME
/
MTIMSTOP
/
MTIMSTOP.ZIP
/
mTimeStop.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1996-10-20
|
4KB
|
132 lines
{----------------------------------------------------------------------
Time Stop - very simple component, that can be used to stop
application to run after specified date.
Copyright (c) 1996 Ahto Tanner, Moon Software. No Rights Reserved.
Please read mTimeStop.txt for more information.
History:
1.1 October 20, 1996
- added OnExpire event,
created by Cezar Goncalves Lenci (sintesis@dglnet.com.br)
- added ShowExpireMessage property. You can turn default message off and
use OnExpire event for custom code/messagebox.
1.0 September 07, 1996
- initial version
-----------------------------------------------------------------------}
unit mTimeStop;
interface
uses
SysUtils, Classes, Dialogs;
type
TmTimeStop = class(TComponent)
private
FDay, FMonth, FYear: integer;
FMessage: string;
FShowExpireMessage: boolean;
FOnExpire: TNotifyEvent;
procedure SetDay( Value: integer );
procedure SetMonth( Value: integer );
procedure SetYear( Value: integer );
protected
procedure Loaded; override;
public
constructor Create( AOwner : TComponent ); override;
published
property Day: integer read FDay write SetDay default 1;
property Month: integer read FMonth write SetMonth default 1;
property Year: integer read FYear write SetYear default 1996;
property Text: string read FMessage write FMessage;
property ShowExpireMessage: boolean read FShowExpireMessage write FShowExpireMessage;
property OnExpire : TNotifyEvent Read FOnExpire Write FOnExpire;
end;
procedure Register;
implementation
{-------------------------------------------------------------------------}
constructor TmTimeStop.Create( AOwner : TComponent );
begin
inherited;
// set default properties
FDay := 1;
FMonth := 1;
FYear := 1996;
FShowExpireMessage := true;
FMessage := 'This version has expired. Please see readme.txt file on ' +
'how to obtain newer version.';
end;
{-------------------------------------------------------------------------}
procedure TmTimeStop.SetDay( Value: integer );
begin
if Value in [1..31] then
FDay := Value
else
ShowMessage( 'Day must be between 1 and 31 as you know.' );
end;
{-------------------------------------------------------------------------}
procedure TmTimeStop.SetMonth( Value: integer );
begin
if Value in [1..12] then
FMonth := Value
else
ShowMessage( 'Month must be between 1 and 12 as you know.' );
end;
{-------------------------------------------------------------------------}
procedure TmTimeStop.SetYear( Value: integer );
begin
if ( Value > 1995 ) AND ( Value < 3000 ) then
FYear := Value
else
ShowMessage( 'Year must be between 1996 and 3000.' );
end;
{-------------------------------------------------------------------------}
procedure TmTimeStop.Loaded;
begin
Inherited Loaded;
if NOT ( csDesigning in ComponentState ) then begin
if Date > EncodeDate( FYear, FMonth, FDay ) then begin
if FShowExpireMessage then begin
Beep;
ShowMessage( FMessage );
end;
if Assigned( FOnExpire ) Then FOnExpire( Self );
Halt;
end;
end;
end;
{-------------------------------------------------------------------------}
procedure Register;
begin
RegisterComponents( 'Moon', [ TmTimeStop ] );
end;
{-------------------------------------------------------------------------}
end.